<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        var i=1;
        function show(){
            console.log("我来自南京第"+i+"次");
            i++;
        }
        function doStart(){
            setInterval(show,1000);
        }


        var j=1;
        function doStart2(){
            console.log("我来自北京"+j+"次");
            j++;//2  
            setTimeout(doStart2,1000);//每次函数执行完毕后，再次开启一个一次性计时器
        }
    </script>
</head>
<body>
    <input type="button" value="周期性计时器" onclick="doStart()">
    <input type="button" value="一次性计时器" onclick="doStart2()">
</body>
</html>